package ${cfg.basePackage}.module.controller;

import ${cfg.basePackage}.commons.annotation.request.RequestLog;
import ${cfg.basePackage}.commons.annotation.request.Resubmit;
import ${cfg.basePackage}.commons.annotation.resource.ResC;
import ${cfg.basePackage}.commons.annotation.resource.ResM;
import ${cfg.basePackage}.mybatis.gen.entity.${entity};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@ResC(ability = "${table.comment!}", author = {"TODO"}, time = "${cfg.date}")
@RestController
@RequestMapping("/${table.entityPath}/${table.entityPath}")
public class ${entity}Controller {
    @Autowired
    ${entity}Service service;

    /**
     * 说明
     * BaseService中的工具类，在ServiceImpl中直接.调用
     * ResC --- 必须写
     * ResM --- 必须写
     * 输出日志用 log.  info/error/debug....
     *
     * @RequestLog() 输出格式化日志，方便调试
     * @Resubmit() 防重复提交注解
     */

    @Resubmit
    @RequestLog
    @ResM(ability = "添加一条数据", author = {"TODO"})
    @RequestMapping({"/insert"})
    public SRS insert(@RequestBody ${entity} param) {
        return service.insert(param);
    }

    @Resubmit
    @RequestLog
    @ResM(ability = "删除数据", author = {"TODO"})
    @RequestMapping({"/delete"})
    public SRS delete(@RequestBody Long[] ids) {
        return service.delete(ids);
    }

    @Resubmit
    @RequestLog
    @ResM(ability = "修改一条数据", author = {"TODO"})
    @RequestMapping({"/update"})
    public SRS update(@RequestBody ${entity} param) {
        return service.update(param);
    }

    @RequestLog
    @ResM(ability = "查询数据集合", author = {"TODO"})
    @RequestMapping({"/list"})
    public SRS list(@RequestBody ${entity} param) {
        return service.list(param);
    }

    @RequestLog
    @ResM(ability = "分页查询数据", author = {"TODO"})
    @RequestMapping("/page")
    public SRS page(@RequestBody SRS param) {
        return service.page(param);
    }

    @RequestLog
    @ResM(ability = "查询一条数据", author = {"TODO"})
    @RequestMapping("/one")
    public SRS one(@RequestBody ${entity} param) {
        return service.one(param);
    }
}
